package org.meb.lotrlcg.db.model;

import java.util.Map;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.MapKey;
import javax.persistence.OneToMany;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Version;

import org.hibernate.annotations.Type;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.NonNull;
import lombok.RequiredArgsConstructor;
import lombok.Setter;
import lombok.ToString;

@Getter
@Setter
@NoArgsConstructor
@RequiredArgsConstructor
@ToString(exclude = { "langItems" })
@Entity
@Table(name = "tb_card")
public class CardBase implements IBase<CardLang> {

	private Integer attack;
	private Integer cost;
	private Integer defense;
	private Integer engageThreat;
	private Integer hitPoints;
	private String illustrator;
	private Integer startingThreat;
	private Integer number;
	private String recordState;
	private Integer quantity;
	private Integer questPoints;
	
	@Enumerated(EnumType.STRING)
	private Sphere sphereCode;
	private String techName;
	private Integer threat;

	@NonNull
	@Enumerated(EnumType.STRING)
	private CardType typeCode;
	
	@Column(name = "unq")
	@Type(type = "org.hibernate.type.YesNoType")
	private Boolean unique;
	private Integer willpower;

	@OneToMany(mappedBy = "base", cascade = CascadeType.ALL)
	@MapKey(name = "langCode")
	@OrderBy(value = "langCode")
	private Map<String, CardLang> langItems;

	@ManyToOne
	@JoinColumn(name = "crst_id")
	private CardSetBase cardSetBase;
	
	@ManyToOne
	@JoinColumn(name = "enst_id")
	private EncounterSetBase encounterSetBase;

	@Id
	@GeneratedValue(strategy = GenerationType.IDENTITY)
	private Long id;
	@Version
	private Long version;
}
